<?php
if ( !defined( "IN_OP" ) )
{
    exit( "You can't access this file directly..." );
}
require_once( "class/CheckMode_6.php" );
$gametype = 0;
$chk = new CheckMode_6( $curruser['acl'], 2 );
$chk->checkShow6Page();
unset( $chk );
if ( $curruser['acl'] != "255" )
{
    exit();
}
$tbl = $g_gametype_3d[$gametype]['en'];
$tblName = $g_gametype_3d[$gametype]['ch'];
$cmd = getvar( "cmd" );
$conf = new Config();
if ( $cmd == "editNote" )
{
    if ( $curruser['acl'] == 255 && $curruser['prev_id'] == 0 )
    {
        $id = intval( getvar( "id" ) );
        $note = getvar( "iptNote" );
        if ( $note != "" )
        {
            if ( $g_conf['language'] == "zh-cn" )
            {
                $note = iconv( "UTF-8", "GB2312", $note );
                include_once( "class/ccharset.php" );
                $cc = new CCharset();
                $note = strip_tags( $note );
                $note = $cc->Gb_Big5( $note );
                $note = htmlspecialchars( $note, ENT_QUOTES );
                header( "Content-type: text/plain; charset=utf-8" );
            }
            else
            {
                $note = iconv( "UTF-8", "big5", $note );
                $note = htmlspecialchars( $note, ENT_QUOTES );
                header( "Content-type: text/plain; charset=GB2312" );
            }
            $sql = "UPDATE lotto SET note = '{$note}' WHERE id ={$id}";
            getdb( $sql );
            header( "Cache-Control: no-cache, must-revalidate" );
            echo "true";
        }
        else
        {
            header( "Content-type: text/plain;" );
            header( "Cache-Control: no-cache, must-revalidate" );
            echo "false";
        }
        exit();
    }
    else
    {
        exit();
    }
}
else
{
    if ( $cmd == "getNote" )
    {
        $id = intval( getvar( "id" ) );
        $sql = "SELECT note FROM lotto WHERE id ={$id}";
        $rs = getdb( $sql );
        $note = $rs->eof ? "" : $rs->f[0];
        if ( $note != "" && $g_conf['language'] == "zh-cn" )
        {
            include_once( "class/ccharset.php" );
            $cc = new CCharset();
            $note = $cc->Big5_Gb( $note );
            header( "Content-type: text/html; charset=GB2312" );
        }
        else
        {
            header( "Content-type: text/html; charset=utf-8" );
        }
        header( "Cache-Control: no-cache, must-revalidate" );
        echo $note;
        exit();
    }
}
?>